package java学习.第05章_数组;

import java.security.SecureRandom;

/**
 * ClassName: F_二维数组的应用
 * Package: java学习.第05章_数组
 * Description:
 *
 * @Author 张蛟龙
 * @Create 2023/3/3 19:45
 * @Version 1.0
 */
public class F_二维数组的应用 {
    public static void main(String[] args) {
        
        //杨辉三角
        int h = 10;
        long[][] longs = new long[h][];
        longs[0] = new long[]{1};
        for (int i = 1; i < longs.length; i++) {
            longs[i] = new long[i+1];
            longs[i][0] = longs[i][i] = 1;
            for (int j = 1; j < longs[i].length-1; j++) {
                longs[i][j] = longs[i-1][j] + longs[i-1][j-1];
            }
        }
        for (int i = 0; i < longs.length; i++) {
            for (int j = 0; j < (h-i) ; j++) {
                System.out.print("\t");
            }
            for (int j = 0; j < longs[i].length; j++) {
                System.out.print(longs[i][j] + "\t\t");
            }
            System.out.println();
        }

    }

    private static void 应用11() {
        SecureRandom sr = new SecureRandom();
        int f = 1555;//范围
        int dx = 99;//范围
        int[] is = new int[dx];
        int sum = 0;
        int max = 0;
        int min = f;
        for (int j = 0; j < is.length; j++) {
            is[j] = sr.nextInt(f);
            if(is[j]>max) max = is[j];
            if(is[j]<min) min = is[j];
            sum += is[j];
        }
        double p = ((double) sum)/is.length;
        System.out.println("最大值：" + max);
        System.out.println("最小值：" + min);
        System.out.println("和：" + sum);
        System.out.println("平均值：" + p);
    }
}
